<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>steps步进动画</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    body {
      width: 100vw;
      height: 100vh;
      background: #2c3e50;
      display: grid;
    }
    main {
      width: 400px;
      height: 200px;
      display: grid;
      grid-template: repeat(2, 1fr)/repeat(4, 1fr);
      position: relative;
    }
    div {
      text-align: center;
      background: #f1c40f;
      border: 1px solid #2c3e50;
      box-sizing: border-box;
    }
    div:nth-child(1)::before {
      content: 'START';
      position: absolute;
      width: 100px;
      height: 100px;
      background: #8e44ad;
      left: 0;right: 0;
      /* animation-timing-function: steps(1, start) */
      animation-timing-function: step-start;
    }
    div:nth-child(5)::before {
      content: 'END';
      position: absolute;
      width: 100px;
      height: 100px;
      background: #27ae60;
      left: 0;right: 0;
      /* animation-timing-function: steps(1, end) */
      animation-timing-function: step-end;
    }
    div:nth-child(1)::before, div:nth-child(5)::before {
      animation-name: move;
      animation-duration: 2s;
      animation-iteration-count: infinite;
    }
    @keyframes move {
      50% {
        transform: translateX(100px);
      }
      to {
        transform: translateX(0px);
      }
    }
  </style>
</head>
<body>
  <main>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    <div>6</div>
    <div>7</div>
    <div>8</div>
  </main>
</body>
</html>